package com.doupi.partner.op.controller.chart;

import com.doupi.partner.service.BusinessRelationService;
import com.doupi.partner.service.ProfitService;
import com.doupi.partner.service.UserRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 数据中心
 *
 * @author zsx
 * @version 1.0.0 @ 2017年4月25日 10:00:13
 */
@Controller
@RequestMapping("chart/{type}")
@Deprecated
public class ChartController {
	private final static String TEMPLATE_FOLDER = "chart/";

	private final BusinessRelationService businessRelationService;

	private final ProfitService profitService;

	private final UserRelationService userRelationService;

	@Autowired
	public ChartController(BusinessRelationService businessRelationService, ProfitService profitService, UserRelationService userRelationService) {
		this.businessRelationService = businessRelationService;
		this.profitService = profitService;
		this.userRelationService = userRelationService;
	}

	// @RequestMapping(value = "index", method = RequestMethod.GET)
	// public String index(ModelMap modelMap, @PathVariable("type") Integer type) {
	// modelMap.put("type", type);
	// return TEMPLATE_FOLDER + "index";
	// }
	//
	// @ResponseBody
	// @RequestMapping(value = "chart", method = RequestMethod.POST)
	// public AjaxResponse list(@PathVariable("type") Byte type, ModelMap modelMap, @RequestParam(value = "beginDate")
	// String beginDate, @RequestParam(value = "endDate") String endDate)
	// throws ParseException {
	// Date beginTime = null;
	// Date endTime = null;
	// if (StringUtils.isNotEmpty(beginDate)) {
	// beginTime = DateUtils.parseDate(beginDate, UtilConstants.YYYY_MM_DD_HH_MM_SS);
	// }
	// if (StringUtils.isNotEmpty(endDate)) {
	// endTime = DateUtils.parseDate(endDate, UtilConstants.YYYY_MM_DD_HH_MM_SS);
	// }
	// DataDto dataDto = new DataDto();
	// dataDto.setBeginTime(beginTime);
	// dataDto.setEndTime(endTime);
	//
	// // 当前用户
	// AdministratorDto administratorDto = OpUtils.getCurrentLoginAdministrator();
	//
	// Profit profit = new Profit();
	// BusinessRelation businessRelation = new BusinessRelation();
	// UserRelation userRelation = new UserRelation();
	//
	// // 封装查询参数
	// ChartUtils.wrapParmas(profit, businessRelation, userRelation, administratorDto);
	//
	// // 系列数据
	// List<SeriesData> seriesData = new ArrayList<>();
	// // 饼图系列列表
	// List<Series> seriesList = new ArrayList<>();
	// switch (type) {
	// case 3: // 商家数据
	// List<PieChartDataDto> businessDataDtos = businessRelationService.queryBusinessForEchartsData(businessRelation,
	// dataDto);
	// BusinessStatusEnum[] businessStatusEnums = BusinessStatusEnum.values();
	// businessStatusEnums = ArrayUtils.removeAll(businessStatusEnums, 0, 4, 5, 6);
	// for (int i = 0; i < businessStatusEnums.length; i++) {
	// BusinessStatusEnum businessStatusEnum = businessStatusEnums[i];
	// SeriesData series = new SeriesData();
	// series.setName(businessStatusEnum.getName());
	// if (businessDataDtos.size() > i) {
	// PieChartDataDto pieChartDataDto = businessDataDtos.get(i);
	// series.setValue(pieChartDataDto.getValue());
	// } else {
	// series.setValue(String.valueOf(UtilConstants.NO));
	// }
	// List<String> data = new ArrayList<>();
	// data.add(String.valueOf(businessStatusEnums[i].getCode()));
	// data.add("business");
	// series.setData(data);
	// seriesData.add(series);
	// }
	// break;
	// case 2: // 收益数据
	// List<PieChartDataDto> pieChartDataDtos = profitService.queryProfitForEchartsData(profit, dataDto);
	// ProfitSourceEnum[] profitSourceEnums = ProfitSourceEnum.values();
	// for (int i = 0; i < profitSourceEnums.length; i++) {
	// ProfitSourceEnum profitSourceEnum = profitSourceEnums[i];
	// SeriesData series = new SeriesData();
	// series.setName(profitSourceEnum.getName());
	// if (pieChartDataDtos.size() > i) {
	// PieChartDataDto pieChartDataDto = pieChartDataDtos.get(i);
	// series.setValue(pieChartDataDto.getValue());
	// } else {
	// series.setValue(String.valueOf(UtilConstants.NO));
	// }
	// List<String> data = new ArrayList<>();
	// data.add(String.valueOf(profitSourceEnums[i].getCode()));
	// data.add("profit");
	// series.setData(data);
	// seriesData.add(series);
	// }
	// break;
	// case 1: // 粉丝数据
	// List<PieChartDataDto> userRelations = userRelationService.queryUserForSumEchartsData(userRelation, dataDto);
	// UserTypeEnum[] userTypeEnums = UserTypeEnum.values();
	// for (int i = 0; i < userTypeEnums.length; i++) {
	// UserTypeEnum userTypeEnum = userTypeEnums[i];
	// SeriesData series = new SeriesData();
	// series.setName(userTypeEnum.getName());
	// if (userRelations.size() > i) {
	// PieChartDataDto pieChartDataDto = userRelations.get(i);
	// series.setValue(pieChartDataDto.getValue());
	// } else {
	// series.setValue(String.valueOf(UtilConstants.NO));
	// }
	// List<String> data = new ArrayList<>();
	// data.add(String.valueOf(userTypeEnums[i].getCode()));
	// data.add("user");
	// series.setData(data);
	// seriesData.add(series);
	// }
	// break;
	// default:
	// throw RuntimeBusinessException.createException("未知的数据类型");
	// }
	// Series series = new PieSeries();
	// series.setData(seriesData);
	// seriesList.add(series);
	//
	// modelMap.put("echartsData", new EchartsData(seriesList));
	// return new AjaxResponse(modelMap);
	// }
}
